﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows;
using IronCommander.Utils;

namespace IronCommander.ViewModels
{
    public class FileViewModel
    {
        public string DisplayName { get; set; }
        public string FullName { get; set; }
        public bool IsFolder { get; set; }
        public DateTime LastWrite { get; set; }
        public long? Size { get; set; }
        public bool IsParentPath { get; set; }

        public string Icon { get { return IsFolder ? KnownResources.FolderIcon : KnownResources.FileIcon; } }

        public FileViewModel()
        {
        }

        public FileViewModel(FileSystemInfo f)
        {
            DisplayName = f.Name;
            FullName = f.FullName;
            IsFolder = EnumEx.IsFlagSet(f.Attributes, FileAttributes.Directory);
            LastWrite = f.LastWriteTime;

            If.Value(f).HasType<FileInfo>(fi => Size = fi.Length);
        }
    }
}
